<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *打卡记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'打卡列表'),
);
if($_RQ['op']=='list'){
	$type=intval($_RQ['type']);
	$params=array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['itemid'])){
		$params['itemid']=intval($_RQ['itemid']);
		$return['params']['itemid']=intval($_RQ['itemid']);
	}
	if(!empty($_RQ['ptile'])){
		$itemid=pdo_getcolumn('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'title like %'=>$_RQ['ptile'].'%'),'id');
		$params['itemid']=intval($_RQ['itemid']);
		$return['params']['itemid']=$_RQ['itemid'];
	}
	if(!empty($_RQ['nickname'])){
		$params['nickname like']='%'.trim($_RQ['nickname']).'%';
		$return['params']['nickname']=$_RQ['nickname'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_aihire_signlog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['membertitle']=pdo_getcolumn('jy_aihire_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['memberid']),'realname');
		$item['membertitle']=$item['membertitle']?:pdo_getcolumn('jy_aihire_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['memberid']),'nickname');
		$item['merchtitle']=pdo_getcolumn('jy_aihire_merch',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['merchid']),'title');
		$item['jobtitle']=pdo_getcolumn('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['jobid']),'title');
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'membertitle','title'=>'用户名称','type'=>'string'),
			array('name'=>'merchtitle','title'=>'用人单位','type'=>'string'),
			array('name'=>'jobtitle','title'=>'任务名称','type'=>'string'),
			array('name'=>'createtime','title'=>'打卡时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'itemid','width'=>15,'title'=>'用人单位','type'=>'string'),
			array('name'=>'ptile','width'=>15,'title'=>'用户名称','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_aihire_signlog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
